<%--
  Created by IntelliJ IDEA.
  User: JAVASM
  Date: 2021/6/23
  Time: 13:13
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>

    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>视频管理</title>
    <%@include file="/common/head.jsp"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

    <style>
        .button{
            margin-top:12px;
           right:229px ;
        }

        .page{
            margin-top:20px;
        }
    </style>

</head>
<body>
<div id="wrapper">
    <%@include file="/common/navi.jsp" %>
    <%--    <这里是中间主体>--%>
    <div id="page-wrapper" class="gray-bg dashbard-1">
        <%@include file="/common/row_head.jsp" %>
        <%--        <可更改地区>--%>
        <%--            <上面的分块 建议不要改div class中的东西>--%>
        <div class="row  border-bottom white-bg dashboard-header">
            <div class="col-sm-3">
                <h2>游戏管理</h2>
            </div>

            <div class="col-sm-2  button">
                <input type="button"  class="btn-danger" value="添加游戏" onclick="jump();" >
            </div>
        </div>
        <%--                <下面的分块 建议不要改div class中的东西>--%>
        <div class="row">
            <div class="col-md-12 column">
                <table class="table table-bordered">
                    <thead>
                    <tr>
                        <th>
                            名称
                        </th>
                        <th>
                            标题
                        </th>
                        <th>
                            下载数
                        </th>
                        <th>
                            大小(M)
                        </th>
                        <th>
                            状态
                        </th>
                        <th>
                            分类
                        </th>
                        <th>
                            平台类型
                        </th>
                        <th>
                            推荐类型
                        </th>
                        <th>
                        &nbsp; &nbsp; &nbsp; &nbsp;
                    </th>
                    </tr>
                    </thead>
                    <tbody id="_tbody">

                    </tbody>
                </table>
            </div>
        </div>

<%--        <div>--%>
        <div class="row ">
            <div class="col-md-5">
                <nav aria-label="Page navigation">
                    <ul class="pagination">
                        <li>
                            <a href="javascript:fristPage()" >
                                <span aria-hidden="true">首页</span>
                            </a>
                        </li>
                        <li><a href="javascript: proPage()">上一页</a></li>
                        <li><a href="javascript: next()">下一页</a></li>

                        <li>
                            <a href="javascript: lastPage()">
                                <span aria-hidden="true">尾页</span>
                            </a>
                        </li>

                    </ul>
                </nav>
            </div>

            <div class="col-md-2 form-inline page">

                <div class="input-group">
                    <div class="input-group-addon">每页</div>
                    <select name="pageSize"  class="form-control" id="pageSize"  onchange="fristPage()">
                        <option value="5">5</option>
                        <option value="10">10</option>
                        <option value="15">15</option>
                    </select>
                    <div class="input-group-addon">条</div>

                </div>
            </div>
            <div class="col-md-1 page" >
                    当前第<span id="pageNum">1</span>页
            </div>
            <div class="col-md-2 page" >
                总<span id="countNum">150</span>条数据
            </div>
        </div>

<%--        <input   type="button" value="修改" class="btn-group" onclick="edit()">--%>
<%--        <input type="button" value="删除" class="btn-danger" onclick="remove()">--%>

<%--        </div>--%>
        <%@include file="/common/foot.jsp"%>
    </div>


    <script>
        (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
            m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
        })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

        ga('create', 'UA-4625583-2', 'webapplayers.com');
        ga('send', 'pageview');


        function jump() {
          location.href="game/add";

        }


    </script>


        <script>
            $(function () {
                //调用 query;
                query();
            })

            function query() {
                var url="game/find";
                var param={
                    "pageNum": $("#pageNum").text(),
                    "pageSize":$("#pageSize").val()
                };
                $.post(url,param,function(data) {
                    console.log(data);
                    $("#_tbody").empty();
                    $.each(data.list,function (index, game) {
                        var html="<tr>"
                        html+="<td>"+game.name+"</td>";
                        html+="<td>"+game.title+"</td>";
                        html+="<td>"+game.downloadCount+"</td>";
                        html+="<td>"+game.size+"</td>";
                        var status="下线";
                        if(game.status==1){
                            status="启用"}
                        html+="<td>"+status+"</td>";
                        html+="<td>"+game.type+"</td>";
                        var platform="all";
                        if(game.platform==2){
                            platform="android"
                        }else if(game.platform==3){
                            platform="ios"
                        }
                        html+="<td>"+platform+"</td>";
                        var recType="普通";
                        if(game.recType==2){recType="最新";}
                        if(game.recType==3){recType="精选";}
                        if(game.recType==4){recType="首页推荐";}
                        html+="<td>"+recType+"</td>";
                        html+="<td>"+"<input   type=\"button\" value=\"修改\" class=\"btn-success\" onclick=\"edit("+game.gid+")\">\n" +
                            "        <input type=\"button\" value=\"删除\" class=\"btn-danger\" onclick=\"remove("+game.gid+")\">"+"</td>";
                        html+="</tr>"
                        $("#_tbody").append(html)
                    })
                    // 调用   pageData方法
                    pageData(data);
                },"json")
            }
   var countNum=0;
            function pageData(data) {
                console.log(data);
                $("#pageNum").text(data.pageNum)
               $("#countNum").text(data.totalNum)
                countNum=data.totalPage;
            }
        </script>

        <script>
            function next() {
                var pageNum= parseInt($("#pageNum").text())+1;
                console.log(pageNum);
                if(pageNum<=countNum){
                    $("#pageNum").text(pageNum);
                    query()
                }

            }

            function jumpPage(pageNum) {
                var pageSize=$("#pageSize").val();
            }
            function proPage(){
                var pageNum= parseInt($("#pageNum").text())-1;
                if(pageNum>0){
                    $("#pageNum").text(pageNum);
                    query();}
            }

            function  lastPage() {
                $("#pageNum").text(countNum);
                query();
            }
            function fristPage() {
                $("#pageNum").text(1);
                    query();
            }

            function edit(gameId) {
                location.href="game/edit?gid="+gameId;
            }
            function remove(gameId) {
                location.href="game/remove?gid="+gameId;
            }
        </script>
</body>
</html>
